package edu.hawaii.myisern.action;

import java.io.IOException;
import java.net.MalformedURLException;
import junit.framework.TestCase;
import org.junit.Test;
import org.xml.sax.SAXException;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebResponse;

/**
 * Tests the AddResearcher Action Bean class
 * 
 * @author Sonwright M. Gomez
 * 
 */
public class TestAddResearcherActionBean extends TestCase {
  /** Get the test host. */
  private String testHost = System.getProperty("test.host");

  /**
   * Tests the AddResearcher Actionbean.
   * 
   * @throws SAXException if error occurs with xml parser.
   * @throws MalformedURLException if error occurs with URL.
   * @throws IOException if error occurs with IO.
   */
  @Test
  public void testAddCollaboration() throws SAXException, MalformedURLException, IOException {
    WebConversation conversation = new WebConversation();

    String pageTitle = "MyIsern - Add Researcher";

    String Url = testHost + "myisern-1-red/addResearcher.jsp";
    WebResponse response = conversation.getResponse(Url);
    assertEquals("Checking addCollaboration.jsp retrieval", pageTitle, response.getTitle());
    
    AddResearcherActionBean res = new AddResearcherActionBean();
    res.setResearcherName("name");
    res.setResearcherBioStatement("bio");
    res.setResearcherEmail("email");
    res.setResearcherOrganization("org");
    res.setResearcherPictureLink("url");
    res.setErrorMessage("ERROR");
    assertSame("name same", "name", res.getResearcherName());
    assertSame("bio same", "bio", res.getResearcherBioStatement());
    assertSame("email same", "email", res.getResearcherEmail());
    assertSame("org same", "org", res.getResearcherOrganization());
    assertSame("url same", "url", res.getResearcherPictureLink());
    assertSame("ERROR same", "ERROR", res.getErrorMessage());
  }
}
